/*
 * TODO this is horrid!!! refactor asap
 */
package com.idea.rdftree.editor;

import java.io.File;
import java.io.FileReader;

import com.hp.hpl.jena.mem.ModelMem;
import com.hp.hpl.jena.rdf.model.Model;


class ModelFileOpener extends Thread {
	
	private final RdfEditor editor;
	
	ModelFileOpener(RdfEditor editor) {
		this.editor = editor;
	}
	File file;

	public void setFile(File file) {
		this.file = file;
	}

	public void run() {
		editor.waitCursor(true);

		Model model = new ModelMem();
		// Model model = editor.getModel();
		try {
			model.read(new FileReader(file), "");
		} catch (Exception exception) {
			//this.editor.logPane.err(exception.getMessage());
			editor.logPrintErr(exception.getMessage());
			exception.printStackTrace();
		}
		editor.logPrintln("Loaded");

		editor.getTreePanel().setTopModel(model);
		editor.getTreePanel().setTopModelFilename( file.toString());
		editor.setModel(model);
		editor.displayModel();

		//	RdfUtils.show(this.editor.treePanel.getTopModel());

	}

}